package architect.algorithn;

/**
 * 五家共井
 *
 * @author guanxin
 * @date 2018/5/7 16:36
 */

public class Well {
    //意思就是说五家人共用一口井，甲家的绳子用两条不够，还要再用乙家的绳子一条才能打到井水；乙家的绳子用三条不够，还要再用丙家的绳子
    //
    //一条才能打到井水；丙家的绳子用四条不够，还要再用丁家的绳子一条才能打到井水；丁家的绳子用五条不够，还要再用戊家的绳子一条才能打
    //
    //到井水；戊家的绳子用六条不够，还要再用甲家的绳子一条才能打到井水。
    //
    //最后问：井有多深？每家的绳子各有多长？

    public static void main(String[] args) {
        solution1();
    }

    private static void solution1() {
        int a, b, c, d, e, h;

        a = b = c = d = e = h = 0;

        boolean flag = true;

        while (flag) {
            //4的倍数
            e += 4;

            a = 0;

            while (flag) {
                //5的倍数
                a += 5;

                d = e + a / 5;

                c = d + e / 4;

                if (c % 2 != 0)
                    continue;

                if (d % 3 != 0)
                    continue;

                b = c + d / 3;

                if (b + c / 2 < a)
                    break;

                if (b + c / 2 == a)
                    flag = false;
            }
        }

        h = 2 * a + b;

        System.out.printf("a=%d，b=%d，c=%d，d=%d，e=%d，============>>>>>>>>>>h=%d\n", a, b, c, d, e, h);
    }

    private static void solution2() {

        for (int k = 1; k < 5; k++) {

            int h = 721 * k;

            int a = 265 * k;

            int b = 191 * k;

            int c = 148 * k;

            int d = 129 * k;

            int e = 76 * k;

            System.out.printf("a=%d，b=%d，c=%d，d=%d，e=%d，============>>>>>>>>>>h=%d\n", a, b, c, d, e, h);
        }
    }
}
